<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>岗位</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/style.css" media="all">
    <script type="text/javascript" src="../../static/js/jquery.min.js"></script>
    <script src="../../layui/layui.all.js" charset="utf-8"></script>
    <script src="../../static/js/base.js" charset="utf-8"></script>
    <script src="../../static/js/ax.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->
</head>
<body class="bg_w">

<div class="layui-fluid">
    <div class="content-wrap">
        <form class="layui-form layui-form-pane" id="from1">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-sm12">
                    <label class="layui-form-label" >部门名称<span
                            class="red">*</span></label>
                    <div class="layui-input-block">
                        <input type="text" name="depName" id="depName" disabled="disabled"  value="" class="layui-input code"
                               lay-verify="required" placeholder="部门名称">
                        <input type="hidden" name="depCode" id="depCode" />
                        <input type="hidden" name="id" id="id" />
                    </div>
                </div>
                <div class="layui-col-sm12">
                    <label class="layui-form-label">岗位代码<span
                            class="red">*</span></label>
                    <div class="layui-input-block">
                        <input type="text" name="code" id="code" value="" class="layui-input code"
                               lay-verify="required|code" placeholder="岗位代码字母+数字，50字符内">
                    </div>
                </div>
                <div class="layui-col-sm12">
                    <label class="layui-form-label">岗位名称<span
                            class="red">*</span></label>
                    <div class="layui-input-block">
                        <input type="text" name="name" id="name" value="" class="layui-input"
                               lay-verify="required|name" placeholder="岗位名称汉字+字母+数字，50字符内">
                    </div>
                </div>
                <div class="layui-col-sm12">
                    <label class="layui-form-label">岗位描述<span
                            class="red">*</span></label>
                    <div class="layui-input-block">
                        <input type="text" name="remarks"  lay-verify="required|remarks" id="remarks" value="" class="layui-input"
                               placeholder="岗位描述汉字+字母+数字，500字符内">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <a id="btnClose" class="layui-btn btn-left layui-btn-primary">关闭</a>
                    <button class="layui-btn add_btn btn-left" lay-submit="" lay-filter="addNews">提交</button>

                </div>
            </div>
        </form>
    </div>
</div>

<script>
    window.onload=function(){
        var  id=decodeURI(getQueryString('id'));
        ax.post({
            type: "post",
            url: schoolWebUrl+"/api/position/getPosition",
            data: {id:id},
            contentType: "application/x-www-form-urlencoded",
            success: function (data) {
                $("#depCode").val(data.data.depCode);
                $("#depName").val(data.data.depName);
                $("#id").val(data.data.id);
                $("#name").val(data.data.name);
                $("#code").val(data.data.code);
                $("#remarks").val(data.data.remarks);
            }
        });
    }
    //关闭弹出
    $('#btnClose').on("click", function () {
        parent.layer.close(parent.layer.getFrameIndex(window.name));
    });
    layui.config({
        base: "js/"
    }).use(['form', 'layer', 'jquery', 'layedit', 'laydate', 'upload'], function () {
        var form = layui.form;
        var layer = parent.layer === undefined ? layui.layer : parent.layer;
        var laypage = layui.laypage;
        var layedit = layui.layedit;
        var laydate = layui.laydate;
        var $ = layui.jquery;

        //添加验证规则
        form.verify({
            code:[
                /^[a-zA-Z][a-zA-Z0-9]{1,50}$/,
                "岗位代码字母+数字，50字符内"
            ],
            name:[
                /^[a-zA-Z0-9\u4e00-\u9fa5]{1,50}$/,
                '岗位名称汉字+字母+数字，50字符内'
            ],
            remarks:[
                /^[a-zA-Z0-9\u4e00-\u9fa5]{1,500}$/,
                '岗位描述汉字+字母+数字，500字符内'
            ],
        });

        form.on("submit(addNews)", function (data) {
           // var index = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
            ax.post({
                type: "post",
                url: schoolWebUrl+"/api/position/updatePosition",
                data: $("#from1").serialize(),
                contentType: "application/x-www-form-urlencoded",
                success: function (data) {
                   // layer.close(index);
                    layer.msg(data.message);
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
                }
            });
            return false;
        });

    })
</script>
</body>
</html>